package com.ruoyi.resume.mapper;

import com.ruoyi.resume.domain.model.ResumeRawData;
import com.ruoyi.resume.provider.ResumeRawDataSqlProvider;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ResumeRawDataMapper {
    @InsertProvider(type = ResumeRawDataSqlProvider.class, method = "insertResumeRawData")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") // 自动获取生成的主键
    Integer saveResume(ResumeRawData resumeRawData);

    /**
     * 根据简历 ID 查询简历所有内容
     *
     * @param resumeId 简历 ID
     * @return 返回简历的原始数据
     */
    @Select("SELECT * FROM resume_raw_data WHERE id = #{resumeId}")
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "pdf_data", property = "pdfData"),
            @Result(column = "resume_data", property = "resumeData"),
            @Result(column = "file_type", property = "fileType"),
            @Result(column = "created_at", property = "createdAt"),
            @Result(column = "updated_at", property = "updatedAt")
    })
    ResumeRawData getResumeById(@Param("resumeId") Integer resumeId);

    /**
     * 根据简历 ID 删除简历
     *
     * @param resumeId 简历 ID
     */
    @Delete("DELETE FROM resume_raw_data WHERE id = #{resumeId}")
    void deleteByResumeId(int resumeId);
}
